{include file="layout/header" title="导航设置" /}
<div class="view-body">
    {include file="layout/menu" /}
    <div class="view-product">
        <div class="company_identify">
            <div class="manage-head">
                <h6 class="padding-left manage-head-con">
                    导航设置
                </h6>
            </div>
            <form action="{:url('admin/Config/save',['key'=>'nav'])}" class="layui-form" method="post" name="navForm">
                <div class="basic-info-detail clearfix">
                    {volist name="navs" id="v"}
                        <div class="layui-form-item margin-left-300 nav-tpl">
                            <div class="layui-form-mid">
                                排序
                            </div>
                            <div class="layui-input-inline" style="width: 80px;">
                                <input class="layui-input" lay-verify="required" name="nav[{$i}][sort]" type="text" value="{$v.sort}">
                                </input>
                            </div>
                            <div class="layui-form-mid">
                                导航名称
                            </div>
                            <div class="layui-input-inline" style="width: 170px;">
                                <input class="layui-input" lay-verify="required" name="nav[{$i}][name]" type="text" value="{$v.name}">
                                </input>
                            </div>
                            <div class="layui-form-mid">
                                链接地址
                            </div>
                            <div class="layui-input-inline" style="width: 300px;">
                                <input class="layui-input" lay-verify="required" name="nav[{$i}][link]" type="text" value="{$v.link}">
                                </input>
                            </div>
                            <div class="layui-input-inline" style="width: 50px;">
                                <input type="checkbox" name="nav[{$i}][show]" {eq name="$v.show" value="1"}checked{/eq} lay-skin="switch" lay-text="显示|隐藏" value="1">
                            </div>
                            <div class="layui-input-inline">
                                <button class="layui-btn layui-btn-primary layui-btn-radius del-nav">
                                    <i class="layui-icon del-nav">&#xe640;</i>
                                </button>
                            </div>
                        </div>
                    {/volist}
                    <div class="layui-form-item margin-left-300">
                        <div class="layui-input-block" style="margin-left: 34px;">
                            <button class="layui-btn layui-btn-primary" id="addNav">
                                <i class="layui-icon"></i>添加导航
                            </button>
                            <button class="layui-btn layui-btn-normal" lay-filter="smsYes" lay-submit="">
                                确定
                            </button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    layui.use(['form','layer'], function(){
        var layer = layui.layer;
        var $ = layui.jquery;
        var form = layui.form();

        $('.del-nav').live('click',function(){
            var len = $(".nav-tpl").length;
            if(len > 1){
                $(this).parent().parent().remove();
                layer.msg('删除成功！');
                return false;
            }else{
                layer.msg('至少保留一条记录！');
                return false;
            }
            return false;
        });
        var i = {$i} + 1;
        $('#addNav').click(function(){

            var tpl =   '<div class="layui-form-item margin-left-300 nav-tpl">' +
                        '<div class="layui-form-mid">排序</div>' +
                        '<div class="layui-input-inline" style="width: 80px;">' +
                            '<input class="layui-input" lay-verify="required" name="nav['+i+'][sort]" type="text" value=""></input>' +
                        '</div>' +
                        '<div class="layui-form-mid">导航名称</div>' +
                        '<div class="layui-input-inline" style="width: 170px;">' +
                            '<input class="layui-input" lay-verify="required" name="nav['+i+'][name]" type="text" value=""></input>' +
                        '</div>' +
                        '<div class="layui-form-mid">链接地址</div>' +
                        '<div class="layui-input-inline" style="width: 300px;">' +
                            '<input class="layui-input" lay-verify="required" name="nav['+i+'][link]" type="text" value=""></input>' +
                        '</div>' +
                        '<div class="layui-input-inline" style="width: 50px;">' +
                            '<input type="checkbox" name="nav['+i+'][show]" lay-skin="switch" checked lay-text="显示|隐藏" value="1">' +
                        '</div>' +
                        '<div class="layui-input-inline">' +
                            '<button class="layui-btn layui-btn-primary layui-btn-radius del-nav"><i class="layui-icon">&#xe640;</i></button>' +
                        '</div></div>';
            $(".nav-tpl:last").after(tpl);
            i = i + 1;
            form.render();
            return false;
        });

    });
</script>
{include file="layout/footer" /}
